<template>
  <div id="app">
    <!-- 通过父组件给子组件传递函数类型的props实现子给父传递数据 -->
    <School :getName="getName" />

    <Student v-on:getStudentName="getStudentName" />
    <!-- <Student ref="student" /> -->
  </div>
</template>

<script>
import School from './components/School'
import Student from './components/Student'

export default {
  name: 'App',
  components: {
    School,
    Student,
  },
  methods: {
    getName(name) {
      console.log('app通过父传子接收到了学校名：', name)
    },
    getStudentName(name) {
      console.log('app通过自定义事件接收到了name：', name)
    }
  },
  mounted() {
    console.log('mounted')
    // this.$refs.student.$on('getStudentName', this.getStudentName)
  }
}
</script>

<style>
#app {
  background: #ccc;
  padding: 10px;
  margin: 10px;
}
</style>
